<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: SendSms
  
    &mdash; Documentation by YARD 0.7.2
  
</title>

  <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '';
  if (relpath != '') relpath += '/';
</script>

  <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="js/app.js"></script>


  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html">Index (S)</a> &raquo; 
    
    
    <span class="title">SendSms</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a id="class_list_link" href="#">Class List</a>
  
    <a id="method_list_link" href="#">Method List</a>
  
    <a id="file_list_link" href="#">File List</a>
  
</div>
      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: SendSms
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">SendSms</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">lib/sendsms.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>
The class which handles sending sms with way2sms
</p>


  </div>
</div>
<div class="tags">
  <h3>Author:</h3>
<ul class="author">
  
    <li>
      
      
      
      
        
        <div class='inline'><p>
Revath S Kumar
</p>
</div>
      
    </li>
  
</ul>

</div>
  <h2>Constant Summary</h2>
  
    <dl class="constants">
      
        <dt id="URL-constant" class="">URL =
          <div class="docstring">
  <div class="discussion">
    <p>
The way2sms root url
</p>


  </div>
</div>
<div class="tags">
  
</div>
        </dt>
        <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>http://site6.way2sms.com</span><span class='tstring_end'>'</span></span></pre></dd>
      
    </dl>
  


  <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#password-instance_method" title="#password (instance method)">- (Object) <strong>password</strong> </a>
    

    
  </span>
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Returns the value of attribute password.
</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#username-instance_method" title="#username (instance method)">- (Object) <strong>username</strong> </a>
    

    
  </span>
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Returns the value of attribute username.
</p>
</div></span>
  
</li>

    
  </ul>




  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#getAction-instance_method" title="#getAction (instance method)">- (String) <strong>getAction</strong> </a>
    

    
  </span>
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Method to fetch the unique identifier in the send sms form.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (SendSms) <strong>initialize</strong>(username, password, auto_logout = true) </a>
    

    
  </span>
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Initiate Sendsms class with way2sms username and password.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#login-instance_method" title="#login (instance method)">- (json) <strong>login</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Login to way2sms.com.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#logout-instance_method" title="#logout (instance method)">- (json) <strong>logout</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
To logout the way2sms session.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#send-instance_method" title="#send (instance method)">- (json) <strong>send</strong>(msisdns, message) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
To send Individual and Group SMS This method support Group SMS from version
0.0.5.
</p>
</div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#send_sms-instance_method" title="#send_sms (instance method)">- (HttpPost) <strong>send_sms</strong>(msisdn, message) </a>
    

    
  </span>
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
The method which post the msisdn, message and unique identifier to way2sms.
</p>
</div></span>
  
</li>

      
        <li class="public deprecated">
  <span class="summary_signature">
    
      <a href="#send_to_many-instance_method" title="#send_to_many (instance method)">- (json) <strong>send_to_many</strong>(msisdns, message) </a>
    

    
  </span>
  
  
  
  
  <span class="deprecated note title">Deprecated</span>
  

  
    <span class="summary_desc"><strong>Deprecated.</strong> <div class='inline'><p>
Use <span class='object_link'><a href="#send-instance_method" title="SendSms#send (method)">#send</a></span> instead of this method
</p>
</div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#set_header-instance_method" title="#set_header (instance method)">- (Json) <strong>set_header</strong>(cookie = nil, referer = nil) </a>
    

    
  </span>
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
To set the Headers for each request.
</p>
</div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#validate-instance_method" title="#validate (instance method)">- (Json) <strong>validate</strong>(msisdn = nil) </a>
    

    
  </span>
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
To validate and format the msisdn passed by the user Format the msisdn into
10 digit.
</p>
</div></span>
  
</li>

      
    </ul>
  

<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <p class="signature first" id="initialize-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="SendSms (class)">SendSms</a></span></tt>) <strong>initialize</strong>(username, password, auto_logout = true) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Initiate Sendsms class with way2sms username and password
</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>username</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
way2sms username
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>password</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
way2sms password
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>auto_logout</span>
      
      
        <span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>true</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
Set to logout after sending SMS. we don&#8217;t need to call the logout
explicitly   Recommended to turn it off when you are sending SMS repeatedly
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


46
47
48
49
50
51
52
53
54</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 46</span>

<span class='kw'>def</span> <span class='id initialize'>initialize</span><span class='lparen'>(</span><span class='id username'>username</span> <span class='comma'>,</span> <span class='id password'>password</span> <span class='comma'>,</span><span class='id auto_logout'>auto_logout</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
  <span class='ivar'>@username</span> <span class='op'>=</span> <span class='id username'>username</span>
  <span class='ivar'>@password</span> <span class='op'>=</span> <span class='id password'>password</span>
  <span class='ivar'>@uri</span> <span class='op'>=</span> <span class='const'>URI</span><span class='period'>.</span><span class='id parse'>parse</span> <span class='const'>URL</span>
  <span class='ivar'>@cookie</span> <span class='op'>=</span> <span class='ivar'>@action</span> <span class='op'>=</span> <span class='kw'>nil</span>
  <span class='ivar'>@referer</span> <span class='op'>=</span> <span class='const'>URL</span>
  <span class='ivar'>@auto_logout</span> <span class='op'>=</span> <span class='id auto_logout'>auto_logout</span>
  <span class='ivar'>@http</span> <span class='op'>=</span> <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTP</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='ivar'>@uri</span><span class='period'>.</span><span class='id host'>host</span><span class='comma'>,</span><span class='ivar'>@uri</span><span class='period'>.</span><span class='id port'>port</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
  
</div>

  <div id="instance_attr_details" class="attr_details">
    <h2>Instance Attribute Details</h2>
    
      
      <span id="password=-instance_method"></span>
      <span id="password-instance_method"></span>
      <div class="method_details first">
  <p class="signature first" id="password-instance_method">
  
    - (<tt>Object</tt>) <strong>password</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Returns the value of attribute password
</p>


  </div>
</div>
<div class="tags">
  
</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


31
32
33</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 31</span>

<span class='kw'>def</span> <span class='id password'>password</span>
  <span class='ivar'>@password</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="username=-instance_method"></span>
      <span id="username-instance_method"></span>
      <div class="method_details ">
  <p class="signature " id="username-instance_method">
  
    - (<tt>Object</tt>) <strong>username</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Returns the value of attribute username
</p>


  </div>
</div>
<div class="tags">
  
</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


31
32
33</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 31</span>

<span class='kw'>def</span> <span class='id username'>username</span>
  <span class='ivar'>@username</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="getAction-instance_method">
  
    - (<tt>String</tt>) <strong>getAction</strong>  <span class="extras">(private)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Method to fetch the unique identifier in the send sms form
</p>


  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
The unique identifier
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


202
203
204
205
206
207</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 202</span>

<span class='kw'>def</span> <span class='id getAction'>getAction</span>
  <span class='id headers'>headers</span> <span class='op'>=</span> <span class='id set_header'>set_header</span> <span class='ivar'>@cookie</span><span class='comma'>,</span> <span class='ivar'>@referer</span>
  <span class='id response'>response</span> <span class='op'>=</span> <span class='ivar'>@http</span><span class='period'>.</span><span class='id get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/jsp/InstantSMS.jsp</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span><span class='id headers'>headers</span><span class='period'>.</span><span class='id delete_if'>delete_if</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id i'>i</span><span class='comma'>,</span><span class='id j'>j</span><span class='op'>|</span> <span class='id j'>j</span><span class='period'>.</span><span class='id nil?'>nil?</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
  <span class='id hdoc'>hdoc</span> <span class='op'>=</span> <span class='const'>Hpricot</span><span class='lparen'>(</span><span class='id response'>response</span><span class='period'>.</span><span class='id body'>body</span><span class='rparen'>)</span>
  <span class='kw'>return</span> <span class='lparen'>(</span><span class='id hdoc'>hdoc</span><span class='op'>/</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>#Action</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id attr'>attr</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>value</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="login-instance_method">
  
    - (<tt>json</tt>) <strong>login</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
Login to way2sms.com
</p>


  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>json</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
A json response with status and message
</p>
<pre class="code">
  <span class='lbrace'>{</span> <span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Login Successful</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
  <span class='lbrace'>{</span> <span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Login Failed</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span></pre>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 65</span>

<span class='kw'>def</span> <span class='id login'>login</span>
  <span class='id data'>data</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>username=</span><span class='tstring_end'>'</span></span><span class='op'>+</span><span class='ivar'>@username</span><span class='op'>+</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>&amp;password=</span><span class='tstring_end'>'</span></span><span class='op'>+</span><span class='ivar'>@password</span>
  <span class='id headers'>headers</span> <span class='op'>=</span> <span class='id set_header'>set_header</span> <span class='ivar'>@cookie</span><span class='comma'>,</span> <span class='ivar'>@referer</span>
  <span class='id response'>response</span> <span class='op'>=</span> <span class='ivar'>@http</span><span class='period'>.</span><span class='id post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/Login1.action</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span><span class='id data'>data</span><span class='comma'>,</span><span class='id headers'>headers</span><span class='period'>.</span><span class='id delete_if'>delete_if</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id i'>i</span><span class='comma'>,</span><span class='id j'>j</span><span class='op'>|</span> <span class='id j'>j</span><span class='period'>.</span><span class='id nil?'>nil?</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
  <span class='kw'>case</span> <span class='id response'>response</span><span class='period'>.</span><span class='id code'>code</span>
    <span class='kw'>when</span>  <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>3\d{2}</span><span class='regexp_end'>/</span></span>
      <span class='kw'>if</span> <span class='id response'>response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>location</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Main.action</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
        <span class='ivar'>@cookie</span> <span class='op'>||=</span> <span class='id response'>response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>set-cookie</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
        <span class='ivar'>@referer</span> <span class='op'>||=</span> <span class='id response'>response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>referer</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
        <span class='ivar'>@action</span> <span class='op'>=</span> <span class='id getAction'>getAction</span>
        <span class='kw'>return</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Login successfully</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
      <span class='kw'>end</span>
      <span class='kw'>return</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Login failed</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
    <span class='kw'>else</span>
      <span class='kw'>return</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Http Error</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="logout-instance_method">
  
    - (<tt>json</tt>) <strong>logout</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
To logout the way2sms session
</p>


  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>json</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
A json with status and message
</p>
<pre class="code">
  <span class='lbrace'>{</span> <span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Logout successfully</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span></pre>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


183
184
185
186
187
188
189
190
191
192</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 183</span>

<span class='kw'>def</span> <span class='id logout'>logout</span>
  <span class='id response'>response</span> <span class='op'>=</span> <span class='ivar'>@http</span><span class='period'>.</span><span class='id get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/jsp/logout.jsp</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='semicolon'>;</span>
  <span class='ivar'>@cookie</span> <span class='op'>=</span> <span class='kw'>nil</span>
  <span class='kw'>case</span> <span class='id response'>response</span><span class='period'>.</span><span class='id code'>code</span>
    <span class='kw'>when</span>  <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>2\d{2}</span><span class='regexp_end'>/</span></span>
      <span class='kw'>return</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Logout successfully</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
    <span class='kw'>else</span>
      <span class='kw'>return</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Logout failed</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="send-instance_method">
  
    - (<tt>json</tt>) <strong>send</strong>(msisdns, message) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
To send Individual and Group SMS This method support Group SMS from version
0.0.5
</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>msisdns</span>
      
      
        <span class='type'>(<tt>Mixed</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
The msisdn/msisdns to send the SMS
</p>
<pre class="code">
  Individual
    A single msisdn as String Eg: &quot;9995436867&quot;
  Group
    An array of msisdns
      Eg: [&quot;9995436867&quot;,&quot;9037107542&quot;,&quot;9037864203&quot;]
    An hash of msisdns
      Eg: {0 =&gt; &quot;9995436867&quot;,1 =&gt; &quot;9037107542&quot;,2 =&gt; &quot;9037864203&quot;}
    A semicolon(;) seperated string of msisdns
      Eg: &quot;9995436867;9037107542;9037864203&quot;</pre>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>message</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
The message to send
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>json</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
A json response with status and message
</p>
<pre class="code">
  <span class='const'>Individual</span>
    <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Send successfull</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
    <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Send failed</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
  <span class='const'>Group</span>
    <span class='lbrace'>{</span>
      <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>9995436867</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Send successfully</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='comma'>,</span>
      <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>9037864203</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Send successfully</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='comma'>,</span>
      <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>9037107542</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Send successfully</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
    <span class='rbrace'>}</span></pre>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 113</span>

<span class='kw'>def</span> <span class='id send'>send</span> <span class='id msisdns'>msisdns</span><span class='comma'>,</span><span class='id message'>message</span>
  <span class='kw'>if</span> <span class='ivar'>@cookie</span><span class='period'>.</span><span class='id nil?'>nil?</span>
    <span class='id login_res'>login_res</span> <span class='op'>=</span> <span class='id login'>login</span>
    <span class='kw'>return</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Login failed</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id login_res'>login_res</span><span class='lbracket'>[</span><span class='symbol'>:success</span><span class='rbracket'>]</span>
  <span class='kw'>end</span>
  <span class='kw'>if</span> <span class='id msisdns'>msisdns</span><span class='period'>.</span><span class='id kind_of?'>kind_of?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id msisdns'>msisdns</span><span class='period'>.</span><span class='id include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='id response'>response</span> <span class='op'>=</span> <span class='id send_sms'>send_sms</span> <span class='id msisdns'>msisdns</span><span class='comma'>,</span><span class='id message'>message</span>
    <span class='id logout'>logout</span> <span class='kw'>if</span> <span class='ivar'>@auto_logout</span>
    <span class='kw'>return</span> <span class='id response'>response</span>
  <span class='kw'>else</span>
    <span class='kw'>if</span> <span class='id msisdns'>msisdns</span><span class='period'>.</span><span class='id kind_of?'>kind_of?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id msisdns'>msisdns</span><span class='period'>.</span><span class='id include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
      <span class='id msisdns'>msisdns</span> <span class='op'>=</span> <span class='id msisdns'>msisdns</span><span class='period'>.</span><span class='id split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>;</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
    <span class='kw'>end</span>
    <span class='id response'>response</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
    <span class='id msisdns'>msisdns</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span> <span class='id key'>key</span><span class='comma'>,</span> <span class='id msisdn'>msisdn</span> <span class='op'>|</span>
      <span class='id msisdn'>msisdn</span> <span class='op'>=</span> <span class='id key'>key</span> <span class='kw'>if</span> <span class='id msisdn'>msisdn</span><span class='period'>.</span><span class='id nil?'>nil?</span>
      <span class='id response'>response</span><span class='lbracket'>[</span><span class='id msisdn'>msisdn</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id send_sms'>send_sms</span> <span class='id msisdn'>msisdn</span><span class='comma'>,</span><span class='id message'>message</span>
    <span class='kw'>end</span>
    <span class='id logout'>logout</span> <span class='kw'>if</span> <span class='ivar'>@auto_logout</span>
    <span class='kw'>return</span> <span class='id response'>response</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="send_sms-instance_method">
  
    - (<tt>HttpPost</tt>) <strong>send_sms</strong>(msisdn, message)  <span class="extras">(private)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
The method which post the msisdn, message and unique identifier to way2sms
</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>msisdn</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
A string of msisdn
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>message</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
A string of message
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>HttpPost</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
The Http post object
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


263
264
265
266
267
268
269
270
271
272
273</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 263</span>

<span class='kw'>def</span> <span class='id send_sms'>send_sms</span> <span class='id msisdn'>msisdn</span><span class='comma'>,</span><span class='id message'>message</span>
  <span class='id headers'>headers</span> <span class='op'>=</span> <span class='id set_header'>set_header</span> <span class='ivar'>@cookie</span><span class='comma'>,</span> <span class='ivar'>@referer</span>
  <span class='id data'>data</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>MobNo=</span><span class='embexpr_beg'>#{</span><span class='id msisdn'>msisdn</span><span class='rbrace'>}</span><span class='tstring_content'>&amp;textArea=</span><span class='embexpr_beg'>#{</span><span class='id message'>message</span><span class='rbrace'>}</span><span class='tstring_content'>&amp;HiddenAction=instantsms&amp;login=&amp;pass=&amp;Action=abfghst5654g</span><span class='tstring_end'>&quot;</span></span>
  <span class='id response'>response</span> <span class='op'>=</span> <span class='ivar'>@http</span><span class='period'>.</span><span class='id post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/quicksms.action?custid=\&quot;+custid+\&quot;&amp;sponserid=\&quot;+sponserid+\&quot;</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span><span class='id data'>data</span><span class='comma'>,</span><span class='id headers'>headers</span><span class='period'>.</span><span class='id delete_if'>delete_if</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id i'>i</span><span class='comma'>,</span><span class='id j'>j</span><span class='op'>|</span> <span class='id j'>j</span><span class='period'>.</span><span class='id nil?'>nil?</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
  <span class='kw'>case</span> <span class='id response'>response</span><span class='period'>.</span><span class='id code'>code</span>
    <span class='kw'>when</span>  <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>2\d{2}</span><span class='regexp_end'>/</span></span>
      <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Send successfully</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
    <span class='kw'>else</span>
      <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Sending failed</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="send_to_many-instance_method">
  
    - (<tt>json</tt>) <strong>send_to_many</strong>(msisdns, message) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <div class="note deprecated"><strong>Deprecated.</strong> <div class='inline'><p>
Use <span class='object_link'><a href="#send-instance_method" title="SendSms#send (method)">#send</a></span> instead of this method
</p>
</div></div>
<p>
To send Group SMS
</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>msisdns</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
A semicolon seperated string of msisdns Eg:
&#8220;9995436867;9037107542;9037864203&#8220;
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>message</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
The message to send
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>json</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
A json response with status and message
</p>
<pre class="code">
  <span class='lbrace'>{</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>9995436867</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Send successfully</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='comma'>,</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>9037864203</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Send successfully</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='comma'>,</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>9037107542</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Send successfully</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
  <span class='rbrace'>}</span></pre>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


158
159
160
161
162
163
164
165
166
167
168
169
170</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 158</span>

<span class='kw'>def</span> <span class='id send_to_many'>send_to_many</span> <span class='id msisdns'>msisdns</span><span class='comma'>,</span> <span class='id message'>message</span>
  <span class='kw'>if</span> <span class='ivar'>@cookie</span><span class='period'>.</span><span class='id nil?'>nil?</span>
    <span class='id login_res'>login_res</span> <span class='op'>=</span> <span class='id login'>login</span>
    <span class='kw'>return</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Login failed</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id login_res'>login_res</span><span class='lbracket'>[</span><span class='symbol'>:success</span><span class='rbracket'>]</span>
  <span class='kw'>end</span>

  <span class='id msisdns'>msisdns</span> <span class='op'>=</span> <span class='id msisdns'>msisdns</span><span class='period'>.</span><span class='id split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>;</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
  <span class='id response'>response</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
  <span class='id msisdns'>msisdns</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span> <span class='id msisdn'>msisdn</span> <span class='op'>|</span>
    <span class='id response'>response</span><span class='lbracket'>[</span><span class='id msisdn'>msisdn</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id send'>send</span> <span class='id msisdn'>msisdn</span><span class='comma'>,</span><span class='id message'>message</span>
  <span class='kw'>end</span>
  <span class='kw'>return</span> <span class='id response'>response</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="set_header-instance_method">
  
    - (<tt>Json</tt>) <strong>set_header</strong>(cookie = nil, referer = nil)  <span class="extras">(private)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
To set the Headers for each request
</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>cookie</span>
      
      
        <span class='type'>(<tt>Sting</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
The cookie which need to set
</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>referer</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
The referer which need to set
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Json</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
A json header
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


220
221
222
223</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 220</span>

<span class='kw'>def</span> <span class='id set_header'>set_header</span><span class='lparen'>(</span><span class='id cookie'>cookie</span><span class='op'>=</span><span class='kw'>nil</span><span class='comma'>,</span><span class='id referer'>referer</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cookie</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='id cookie'>cookie</span> <span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Referer</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='id referer'>referer</span> <span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Content-Type</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>application/x-www-form-urlencoded</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>User-Agent</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20091020 Ubuntu/9.10 (karmic) Firefox/3.5.3 GTB7.0</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="validate-instance_method">
  
    - (<tt>Json</tt>) <strong>validate</strong>(msisdn = nil)  <span class="extras">(private)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
To validate and format the msisdn passed by the user Format the msisdn into
10 digit. Accepted Formats
</p>
<pre class="code">
  
  00919995436867
  +919995436867
  919995436867
  9995436867</pre>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>msisdn</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>
The msisdn which need to validated
</p>
</div>
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Json</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
A Json with status and message
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


242
243
244
245
246
247</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sendsms.rb', line 242</span>

<span class='kw'>def</span> <span class='id validate'>validate</span><span class='lparen'>(</span><span class='id msisdn'>msisdn</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
  <span class='id result'>result</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(\+|00)?(91)?(9|8|7)[0-9]{9}$</span><span class='regexp_end'>/</span></span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='id msisdn'>msisdn</span><span class='rparen'>)</span>
  <span class='kw'>return</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Invalid Msisdn</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id result'>result</span><span class='period'>.</span><span class='id nil?'>nil?</span>
  <span class='id msisdn_formated'>msisdn_formated</span> <span class='op'>=</span> <span class='id result'>result</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>10</span><span class='op'>..</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
  <span class='kw'>return</span> <span class='lbrace'>{</span><span class='symbol'>:success</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span><span class='symbol'>:message</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Valid Msisdn</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span><span class='symbol'>:msisdn</span> <span class='op'>=&gt;</span> <span class='id msisdn_formated'>msisdn_formated</span><span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Sun Mar  4 10:17:36 2012 by 
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.7.2 (ruby-1.9.2).
</div>

  </body>
</html>